package cn.iocoder.yudao.module.product.enums.spu;

import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 售卖渠道
 * 0: 所有，1：支付宝，2：微信
 */
@Getter
@AllArgsConstructor
public enum ProductSalesChannelEnum implements IntArrayValuable {

    ALL(0, "通用"),
    ALIPAY(1, "支付宝"),
    WECHAT(2, "微信"),
    BINANCE(3, "币安")
            ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSalesChannelEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    /**
     * 状态
     */
    private final Integer value;
    /**
     * 状态名
     */
    private final String name;

    public static ProductSalesChannelEnum fromStatus(Integer value) {
        for (ProductSalesChannelEnum channelEnum : values()) {
            if (channelEnum.getValue().equals(value)) {
                return channelEnum;
            }
        }
        throw new IllegalArgumentException("未知的value：" + value);
    }
}
